﻿
using QFramework;
using System.Collections.Generic;

namespace ProjectIndieFarm
{
    /// <summary>
    /// 拥有至少10个胡萝卜
    /// </summary>
    public class CHLG_Have10Carrot : Challenge, IUnRegisterList
    {
        public override string Name => "拥有至少10个胡萝卜";

        private int mCarrotCount = 0;

        public override bool CheckFinish()
        {
            return Global.Days.Value != StartDate
                && mCarrotCount >= 10;
        }
        public override void OnStart()
        {
            ToolbarSystem.OnItemCountChange.Register((item, count) =>
            {
                if (item.ItemID.Value == "item_carrot")
                {
                    mCarrotCount = count;
                }
            }).AddToUnregisterList(this);
        }
        public override void OnFinish()
        {
            this.UnRegisterAll();
        }
        public List<IUnRegister> UnregisterList => new List<IUnRegister>();
    }
}
